﻿using LxBasic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LxCore
{
    public struct Bound3d
    {
        public Bound3d()
        {
            MinX = double.PositiveInfinity;
            MinY = double.PositiveInfinity;
            MinZ = double.PositiveInfinity;
            MaxX = double.NegativeInfinity;
            MaxY = double.NegativeInfinity;
            MaxZ = double.NegativeInfinity;
        }
        public Bound3d(Vector3d d)
        {
            MinX = d.X;
            MinY = d.Y;
            MinZ = d.Z;
            MaxX = d.X;
            MaxY = d.Y;
            MaxZ = d.Z;
        }
        public double MinX;
        public double MinY;
        public double MinZ;
        public double MaxX;
        public double MaxY;
        public double MaxZ;
        public void Include(Vector3d v)
        {
            if (v.X < MinX) MinX = v.X;
            if (v.Y < MinY) MinY = v.Y;
            if (v.Z < MinZ) MinZ = v.Z;
            if (v.X > MaxX) MaxX = v.X;
            if (v.Y > MaxY) MaxY = v.Y;
            if (v.Z > MaxZ) MaxZ = v.Z;
        }
        public override string ToString()
        {
            return string.Format($"X范围[{MinX},{MaxX}],Y范围[{MinY},{MaxY}],Z范围[{MinZ},{MaxZ}]");
        }
    }
}
